package com.boot.unity.api.modules.training.dao;

import com.boot.unity.api.modules.training.entity.Institution;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface InstitutionDao {

    @Select("select * from training_institution t where t.id = #{id}")
    Institution getById(Long id);

    @Delete("delete from training_institution where id = #{id}")
    int delete(Long id);

    int update(Institution institution);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into training_institution(inscode, district, name, shortname, licnum, licetime, business, creditcode, address, postcode, legal, contact, phone, busiscope, busistatus, level, coachnumber, grasupvnum, safmngnum, tracarnum, classroom, thclassroom, praticefield, createTime, updateTime) values(#{inscode}, #{district}, #{name}, #{shortname}, #{licnum}, #{licetime}, #{business}, #{creditcode}, #{address}, #{postcode}, #{legal}, #{contact}, #{phone}, #{busiscope}, #{busistatus}, #{level}, #{coachnumber}, #{grasupvnum}, #{safmngnum}, #{tracarnum}, #{classroom}, #{thclassroom}, #{praticefield}, now(), now())")
    int save(Institution institution);
    
    int count(@Param("params") Map<String, Object> params);

    List<Institution> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);

    @Select("select * from training_institution where inscode = #{inscode}")
    Institution getByInscode(@Param("inscode") String inscode);

    int updateByInscode(Institution institution);
}
